import requests
import json
url = 'https://movie.douban.com/j/chart/top_list?'
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.95 Safari/537.36'}
param = {'type': '24',
         'interval_id': '100:90',
         'action': ' ',
         'start': '0',# 从库中的第几部电影去取
         'limit': '20'}# 一次取出的个数
response = requests.get(url=url,params=param,headers=headers)
list_date = response.json()
fp = open('./douban.json','w',encoding='utf-8')
json.dump(list_date,fp=fp,ensure_ascii=False)
print('成功')